package 华为OD机试真题2023.基础题;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class HJ40_知识图谱新词挖掘1 {
  public static void main(String[] args) throws FileNotFoundException {
    Scanner in = new Scanner(new File("src/main/java/华为OD机试真题2023/基础题/input/40.txt"));
    String s1 = in.nextLine();
    String s2 = in.nextLine();
    char[] s2Char = s2.toCharArray();
    Arrays.sort(s2Char);
    int len2 = s2.length();
    int len1 = s1.length();
    if (len1 < len2) {
      System.out.println(0);
      return;
    }
    int res = 0;
    for (int i = 0; i <= len1 - len2; i++) {
      char[] cur = s1.substring(i, len2 + i).toCharArray();
      Arrays.sort(cur);
      if (isCheck(s2Char, cur)) {
        res++;
      }
    }
    System.out.println(res);
  }

  static boolean isCheck(char[] a, char[] b) {
    for (int i = 0; i < a.length; i++) {
      if (a[i] != b[i]) {
        return false;
      }
    }
    return true;
  }
}
